﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="newPolicy.aspx.cs" Inherits="AutoInsurance.newPolicy" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style1
        {
            font-size: large;
        }
        .style2
        {
            font-size: medium;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2 style="color: #0000FF">
            <asp:HyperLink ID="HyperLink2" runat="server" 
            NavigateUrl="~/Default.aspx">Вернуться на главную</asp:HyperLink>
            <asp:Label ID="Label4" runat="server" Text="Label" Visible="False"></asp:Label>
            <asp:Label ID="Label6" runat="server" Text="Label" Visible="False"></asp:Label>
    </h2>
    <h2>Выберите клиента из списка:
    <asp:Label ID="Label2" 
            runat="server" Text="Label" Visible="False"></asp:Label>

        <asp:DropDownList ID="DropDownList1" runat="server" Visible="False">
        </asp:DropDownList>

    </h2>
    <h2>
        <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
            AutoGenerateColumns="False" DataKeyNames="id_client" DataSourceID="SqlDataSource1"  
            onselectedindexchanged="GridView1_SelectedIndexChanged">
            <Columns>
                <asp:CommandField ShowEditButton="True" ShowDeleteButton="True" 
                    ShowSelectButton="True" />
                
                <asp:BoundField DataField="name" HeaderText="Имя" SortExpression="name" />
                <asp:BoundField DataField="surname" HeaderText="Фамилия" 
                    SortExpression="surname" />
                <asp:BoundField DataField="ratings" HeaderText="Паспортные данные" 
                    SortExpression="ratings" />
                <asp:BoundField DataField="birthdate" HeaderText="Дата рождения" SortExpression="birthdate" />
                <asp:BoundField DataField="Phone" HeaderText="Номер телефона" SortExpression="Phone" /> 
            </Columns>
            <SelectedRowStyle />
        </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:AUTOINSURANCEConnectionString %>" 
            DeleteCommand="DELETE FROM [Client] WHERE [id_client] = @id_client" 
            InsertCommand="INSERT INTO [Client] ([ratings], [birthdate], [name], [surname], [phone]) VALUES (@ratings, @birthdate, @name, @surname, @phone)" 
            SelectCommand="SELECT * FROM [Client]" 
            UpdateCommand="UPDATE [Client] SET [ratings] = @ratings, [birthdate] = @birthdate, [ratings] = @ratings, [name] = @name, [surname] = @surname, [Phone] = @Phone WHERE [id_client] = @id_client">
            <DeleteParameters>
                <asp:Parameter Name="id_client" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="ratings" Type="String" />
                <asp:Parameter Name="birthdate" Type="DateTime" />
                <asp:Parameter Name="name" Type="String" />
                <asp:Parameter Name="surname" Type="String" />
                <asp:Parameter Name="Phone" Type="String" />
                <asp:Parameter Name="id_client" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="ratings" Type="String" />
                <asp:Parameter Name="birthdate" Type="DateTime" />
                <asp:Parameter Name="name" Type="String" />
                <asp:Parameter Name="surname" Type="String" />
                <asp:Parameter Name="Phone" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/newClient.aspx">Или добавьте нового</asp:HyperLink>

    </h2>
    <asp:Panel ID="Panel1" runat="server" Height="269px" Visible="False" 
        Width="442px">
    <table >
            <tr>
                <td> <span class="style1"><strong>Данные об автомобиле</strong></span>:</td>
            </tr>
          <tr>
                <td class="style2">
                    VIN-код  
                </td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server" CssClass="style2"></asp:TextBox>
                    <asp:RequiredFieldValidator id="RequiredFieldValidator3"
                    ControlToValidate="TextBox1"
                    Display="Static"
                    ErrorMessage="RequiredFieldValidator"
                    runat="server"> Нужно ввести VIN-код</asp:RequiredFieldValidator>  
                </td>
            </tr><tr>
                <td class="style2">
                    Марка автомобиля 
                </td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server" CssClass="style2"></asp:TextBox>
                    <asp:RequiredFieldValidator id="RequiredFieldValidator4"
                    ControlToValidate="TextBox2"
                    Display="Static"
                    ErrorMessage="RequiredFieldValidator"
                    runat="server"> Нужно ввести марку автомобиля</asp:RequiredFieldValidator>  
                </td>
            </tr>
            <tr>
                <td class="style2">
                   Модель автомобиля  
                </td>
                <td>
                    <asp:TextBox ID="TextBox4" runat="server" CssClass="style2"></asp:TextBox>
                    <asp:RequiredFieldValidator id="RequiredFieldValidator5"
                    ControlToValidate="TextBox4"
                    Display="Static"
                    ErrorMessage="RequiredFieldValidator"
                    runat="server"> Нужно ввести модель автомобиля</asp:RequiredFieldValidator>    
                </td>
            </tr>
            <tr>
                <td class="style2">
                    Мощность (л/с)  
                </td>
                <td>
                    <asp:TextBox ID="TextBox5" runat="server" CssClass="style2"></asp:TextBox>
                    <asp:RequiredFieldValidator id="RequiredFieldValidator6"
                    ControlToValidate="TextBox5"
                    Display="Static"
                    ErrorMessage="RequiredFieldValidator"
                    runat="server"> Нужно ввести мощность</asp:RequiredFieldValidator>    
                </td>
                </tr>
            </table>
        <p >
            <asp:Button ID="Button2" runat="server" Text="Далее" 
                onclick="Button2_Click" />
        </p>
            
            
        <p>
            <asp:Label ID="Label5" runat="server" Text="Новое авто успешно добавлено!" 
                Visible="False"></asp:Label>
        </p>
            
            
    </asp:Panel>
    <asp:Panel ID="Panel2" runat="server" Height="425px" Width="477px" 
        Visible="False">
     <table style="height: 365px; width: 155%;">
            <tr>
                <td class="style1"> <strong>Данные для полиса:</strong></td>
            </tr>
          <tr>
                <td class="style2">
                    Вид страхования  
                </td>
                <td>
                        <asp:RadioButtonList ID="RadioButtonList2" runat="server">
        <asp:ListItem Selected="True">ОСАГО</asp:ListItem>
        <asp:ListItem>КАСКО</asp:ListItem>
    </asp:RadioButtonList>
     
                </td>
            </tr><tr>
                <td class="style2">
                    Стаж вождения (лет) 
                </td>
                <td>
                    <asp:TextBox ID="TextBox3" runat="server" ></asp:TextBox>
    <asp:RequiredFieldValidator id="RequiredFieldValidator2"
                    ControlToValidate="TextBox3"
                    Display="Static"
                    ErrorMessage="RequiredFieldValidator"
                    runat="server"> Нужно ввести cтаж вождения</asp:RequiredFieldValidator>  
                </td>
            </tr><tr>
                <td class="style2">
                    Возраст водителя  
                </td>
                <td>
                    <asp:ListBox ID="ListBox2" runat="server" >
        <asp:ListItem Value="2" Selected="True">от 18 до 22 лет включительно</asp:ListItem>
        <asp:ListItem Value="1">более 22 лет</asp:ListItem>
    </asp:ListBox>
                </td>
            </tr><tr>
                <td class="style2">
                    Категория  
                </td>
                <td>
                    <asp:ListBox ID="ListBox1" runat="server">
        <asp:ListItem Value="Мотоциклы и мотороллеры">Мотоциклы и мотороллеры</asp:ListItem>
        <asp:ListItem Selected="True">Легковые автомобили</asp:ListItem>
        <asp:ListItem>Грузовые автомобили</asp:ListItem>
    </asp:ListBox> 
                </td>
            </tr><tr>
                <td class="style2">
                     Лица, допущенные к управлению  
                </td>
                <td>
                    <asp:RadioButtonList ID="RadioButtonList1" runat="server">
        <asp:ListItem Selected="True">Без ограничений</asp:ListItem>
        <asp:ListItem>Ограниченный список</asp:ListItem>
    </asp:RadioButtonList>
                </td>
            </tr>
                        <tr>
                <td class="style2">
                    Дата окончания (в формате dd/mm/yyyy)
                </td>
                <td>
                    <asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>  
                    <asp:RequiredFieldValidator id="RequiredFieldValidator1"
                    ControlToValidate="TextBox7"
                    Display="Static"
                    ErrorMessage="RequiredFieldValidator"
                    runat="server"> Нужно ввести дату окончания</asp:RequiredFieldValidator>
                    <asp:CompareValidator ID="CompareValidator3" runat="server" ControlToValidate="TextBox7" 
                    ErrorMessage="Неверный формат даты!" Operator="DataTypeCheck" Type="Date" Display="Dynamic" 
                    ValueToCompare="MM/dd/yyyy"></asp:CompareValidator> 
                </td>

            </tr>
            <tr>
                <td class="style1" style="font-size: large">
                    <span class="style2">Стоимость полиса </span>  
                    <asp:Button ID="Button3" runat="server" onclick="Button3_Click" 
                        Text="Рассчитать" CssClass="style2" />
                </td>
                <td>
                    <asp:TextBox ID="TextBox12" runat="server"></asp:TextBox>   
                </td>
            </tr>
            </table>
        <br />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
            Text="Добавить полис" Visible="False" />

        <asp:Label ID="Label3" runat="server" Text="Новый полис успешно добавлен!" 
            Visible="False"></asp:Label>

    </asp:Panel>

</asp:Content>
